<?php
class Admin_Model_Tintucitem extends Zend_Db_Table_Abstract{
    protected $_name='table_news_item';
    protected $_primary='id';
    protected $_sequence=true;    
    
    public function getAll(){        
        $se=$this->select(SELECT_WITH_FROM_PART);
        $se->setIntegrityCheck(false);
        
        $ta_news_cat=new Admin_Model_Tintuccat;
        $cols=$ta_news_cat->info(Zend_Db_Table_Abstract::COLS);        
        $news_cat_cols=array();
        foreach($cols as $item){            
            $news_cat_cols[]=$item.' as news_cat_'.$item;
        }
        
        $se->join(array('c'=>'table_news_cat'),
        'table_news_item.id_cat=c.id',
        $news_cat_cols);
        
        //print($this->fetchAll($se));die();                
        if($kq=$this->fetchAll($se))
            return $kq->toArray();
        else
            return false;            
    }
    
    public function getWhere($id){
        $se=$this->select();
        $se->where("id=$id");        
        if($kq=$this->fetchRow($se))
            return $kq->toArray();
        else
            return false;  
    }
    
    public function getArrWhere($id_cat){
        $se=$this->select();
        $se->where("id_cat=$id_cat");        
        if($kq=$this->fetchAll($se))
            return $kq->toArray();
        else
            return false;  
    }
    
    public function updateItem($data,$id){
        $this->update($data,"id=$id");          
    }
    
    
    
}

